package com.tensai.teach.beijing.utils.files;

import com.tensai.teach.beijing.model.now.Lane;
import com.tensai.teach.beijing.model.now.LaneAttributes;
import com.tensai.teach.beijing.model.old.base.MapData;
import com.tensai.teach.beijing.model.old.base.second.features.geometry.OtherGeo;
import com.tensai.teach.beijing.model.old.base.second.features.properties.LaneProperties;
import com.tensai.teach.beijing.utils.EntityServiceUtil;

import java.util.List;
import java.util.stream.Collectors;

public class LaneService {


	public List<Lane> findByRoadId(Long roadId) {
		MapData<LaneProperties, OtherGeo> lane = EntityServiceUtil.getLane();
		return lane.getFeatures().stream()
				.filter(it->it.getProperties().getRoadId().equals(roadId))
				.map(it -> Lane.builder()
						.laneId(it.getProperties().getLaneId())
						.laneAttributes(LaneAttributes.builder()
								.shareWidth(null)
								.laneType(it.getProperties().getType())
								.build()
						)
						.maneuvers(15)
						.speedLimits(null)
						.lanePoints(it.getGeometry().makeBmapPointList())
						.build()).collect(Collectors.toList());
	}
}
